﻿Imports System.Data.SqlClient

Public Class clsFormularios
    Private mintidFormulario As Integer
    Private mstrNombre As String
    Private mstrTipo As String
    Private mstrFormulario As String
    Private mstrFamilia As String
    Private mstrDescripcion As String
   
    Public Property idFormulario() As Integer
        Get
            Return mintidFormulario
        End Get
        Set(ByVal value As Integer)
            mintidFormulario = value
        End Set
    End Property
    Public Property Nombre() As String
        Get
            Return mstrNombre
        End Get
        Set(ByVal value As String)
            mstrNombre = value
        End Set
    End Property
   
    Public Property Tipo() As String
        Get
            Return mstrTipo
        End Get
        Set(ByVal value As String)
            mstrTipo = value
        End Set
    End Property
    Public Property Formulario() As String
        Get
            Return mstrFormulario
        End Get
        Set(ByVal value As String)
            mstrFormulario = value
        End Set
    End Property
    Public Property Familia() As String
        Get
            Return mstrFamilia
        End Get
        Set(ByVal value As String)
            mstrFamilia = value
        End Set
    End Property
    Public Property Descripcion() As String
        Get
            Return mstrDescripcion
        End Get
        Set(ByVal value As String)
            mstrDescripcion = value
        End Set
    End Property
    Public Sub New()
        mintidFormulario = 0
        mstrNombre = ""
        mstrTipo = ""
        mstrFormulario = ""
        mstrFamilia = ""
        mstrDescripcion = ""
    End Sub
    Public Sub Insertar()
        Dim sql As String = "Insert Into Formularios ( " & _
                            "Nombre,Tipo,Formulario,Familia,Descripcion) Values (@Nombre,@Tipo,@Formulario,@Familia,@Descripcion)"
        Dim cnConn As New SqlConnection
        cnConn.ConnectionString = InitialConnection

        Dim Command As New SqlCommand(sql, cnConn)

        Command.Parameters.AddWithValue("Nombre", mstrNombre)
        Command.Parameters.AddWithValue("Tipo", mstrTipo)
        Command.Parameters.AddWithValue("Formulario", mstrFormulario)
        Command.Parameters.AddWithValue("Familia", mstrFamilia)
        Command.Parameters.AddWithValue("Descripcion", mstrDescripcion)


        cnConn.Open()
        Dim RowsAffected As Integer = Command.ExecuteNonQuery

        If RowsAffected > 0 Then
            'cnConn.Close()
            'MsgBox("Empresa Creada con Exito", MsgBoxStyle.Information, "Aviso")

        Else
            MsgBox("No fue posible insertar el formulario", MsgBoxStyle.Exclamation, "Aviso")
            If cnConn.State = ConnectionState.Open Then
                cnConn.Close()
            End If
        End If

    End Sub
End Class
